package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Refund;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class RefundVO {

    @ApiModelProperty(value = "主表id")
    private Integer id;

    @ApiModelProperty(value = "生产单id")
    private Integer produceId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "退款标题")
    private String title;

    @ApiModelProperty(value = "退款原由")
    private String reason;

    @ApiModelProperty(value = "退款金额")
    private Double refundMoney;

    @ApiModelProperty(value = "退款人")
    private Integer refundAdminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "状态：0待审核，1通过，2不通过，3作废，4，删除")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "退钱产品列表")
    private List<RefundProductVO> refundProducts;

    @ApiModelProperty(value = "免审字段")
    private Integer exempt;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Refund convert(RefundVO vo) {
        Refund entity = new Refund();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Refund> convertList(List<RefundVO> list) {
        List<Refund> resultList = new ArrayList<>();
        for (RefundVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
